package view;

import controller.ManageDetailsListener;
import pojo.Manage;

import javax.swing.*;
import java.awt.*;

public class ManageDetails extends JDialog {
    private JLabel labelUId,labelUName,labelBId,labelBName,labelLend,labelReturn;
    private JTextField tfUId,tfUName,tfBId,tfBName,tfLend,tfReturn;
    private Manage manage;
    private ManageView manageView;
    private ManageDetailsListener manageDetailsListener;
    public ManageDetails(Manage manage,ManageView manageView) {
        this.manage=manage;
        this.manageView=manageView;
        manageDetailsListener=new ManageDetailsListener(this,manageView);

        this.setTitle("借阅信息");
        this.setSize(400, 500);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        this.setLayout(new BorderLayout());
        this.add(this.getPanel(), BorderLayout.CENTER);
        this.add(this.getButton(), BorderLayout.SOUTH);
    }
        public JPanel getPanel(){
            JPanel jPanel=new JPanel();
            jPanel.setLayout(new GridLayout(6,2));
            labelUId=new JLabel("                             学号：");
            labelUName=new JLabel("                             姓名：");
            labelBId=new JLabel("                             书号：");
            labelBName=new JLabel("                             书名：");
            labelLend=new JLabel("                         借入时间：");
            labelReturn=new JLabel("                         期限时间：");
            tfUId=new JTextField(manage.getBookId(),15);
            tfUName=new JTextField(manage.getBookName(),15);
            tfBId=new JTextField(manage.getUserId(),15);
            tfBName=new JTextField(manage.getUserName(),15);
            tfLend=new JTextField(manage.getLendTime(),15);
            tfReturn=new JTextField(manage.getReturnTime(),15);
            tfUId.setEditable(false);
            tfUName.setEditable(false);
            tfBId.setEditable(false);
            tfBName.setEditable(false);
            tfLend.setEditable(false);
            tfReturn.setEditable(false);
            jPanel.add(labelUId);
            jPanel.add(tfUId);

            jPanel.add(labelUName);
            jPanel.add(tfUName);

            jPanel.add(labelBId);
            jPanel.add(tfBId);

            jPanel.add(labelBName);
            jPanel.add(tfBName);

            jPanel.add(labelLend);
            jPanel.add(tfLend);

            jPanel.add(labelReturn);
            jPanel.add(tfReturn);

            return jPanel;
        }
        public JPanel getButton(){
        JPanel panel=new JPanel();
        JButton button1=new JButton("续借");
        JButton button2=new JButton("删除记录");
        JButton button3=new JButton("返回");
        button1.addActionListener(manageDetailsListener);
            button2.addActionListener(manageDetailsListener);
            button3.addActionListener(manageDetailsListener);
        panel.add(button1);
            panel.add(button2);
            panel.add(button3);
        return panel;
        }

    public JLabel getLabelUId() {
        return labelUId;
    }

    public JTextField getTfUId() {
        return tfUId;
    }

    public JTextField getTfUName() {
        return tfUName;
    }

    public JTextField getTfBId() {
        return tfBId;
    }

    public JTextField getTfBName() {
        return tfBName;
    }

    public JTextField getTfLend() {
        return tfLend;
    }

    public JTextField getTfReturn() {
        return tfReturn;
    }

    public Manage getManage() {
        return manage;
    }
}

